#include "CMinionInfoPanel.h"

#include "CMinion.h"
#include "CLabelAdder.h"

CMinionInfoPanel::CMinionInfoPanel(IrrlichtDevice *device, IGUIElement *parent, CMinion *pMinion, s32 x, s32 y)
{
  IGUIEnvironment *env = device->getGUIEnvironment();
  IVideoDriver *driver = device->getVideoDriver();

  if (env == 0)
  {
    cout << "FATAL ERROR: CMinionInfoPanel received null env pointer." << endl;
    return;
  }

  s32 w = 440;
  s32 h = 340;

  short lf, rt, up, dn;
  lf = x;
  up = y;
  rt = lf + w;
  dn = up + h;

  minionStats& stats = pMinion->getStats();
  stringw temp;
  base = env->addImage(rect<s32>(lf, up, rt, dn), parent);
  base->setImage(driver->getTexture("frame.png"));
  base->setScaleImage(true);
  base->setUseAlphaChannel(true);

  env->addStaticText(L"", rect<s32>(215, 15, 425, 325), true, true, base);
  IGUIImage *minionPic = env->addImage( rect<s32>(220,20,420,320), base);
  minionPic->setImage(CMinion::getMinionPic(stats.typeName));
  minionPic->setScaleImage(true);

  CLabelAdder adder(env, base, 25, 25, 100, 75);
  adder.addLabel(stats.name.c_str());
  adder.addLabel(stats.typeName.c_str());
  adder.addLabel(L"Level: ", stats.level);
  adder.addLabel(L"HP: ", stats.maxHp);
  adder.addLabel(L"MP: ", stats.maxMp);
  adder.addLabel(L"Attack: ", stats.atk);
  adder.addLabel(L"Defend: ", stats.def);
  adder.addLabel(L"Magic Attack: ", stats.mAtk);
  adder.addLabel(L"Magic Defend: ", stats.mDef);
  adder.addLabel(L"Movement: ", int(stats.movement));
  adder.addLabel(L"Range: ", int(stats.range));
}

CMinionInfoPanel::~CMinionInfoPanel()
{
  base->remove();
}
